package com.huaao.micropolice.core.repository.system;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Repository;

import com.huaao.micropolice.core.common.page.Sort;
import com.huaao.micropolice.core.model.system.Area;
import com.huaao.micropolice.core.model.system.Dept;
import com.huaao.micropolice.core.repository.BaseDao;

@Repository
public class DeptDao extends BaseDao{
	
	@Override
	public String save(Object obj) {
		return super.save(obj);
	}

	public Dept load(String id) {
		return (Dept) load(Dept.class, id);
	}
	
	public List<Dept> findByDeptParentId(String id) {
		List<Dept> items = null;
		items = getSession().createQuery("FROM Dept where parent.id = ? order by name").setString(0, id).list();
		return items;
	}

	public List<Dept> findAll() {
		List<Dept> depts = getSession().createQuery("FROM Dept order by name").list();
		return depts;
	}
	
	public List<Dept> findByAreaId(String id){
		List<Dept> items = null;
		items = getSession().createQuery("FROM Dept where area.id = ? order by name").setString(0, id).list();
		return items;
	}
}
